/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.rbh.risk.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;
import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 *
 * @author IT-Mafia
 */
@Entity
@Table(name = "rbh_risk_main_cause")
@XmlRootElement
public class MainCause implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "MAIN_CAUSE_ID", unique = true, nullable = false, columnDefinition = "smallint UNSIGNED")
    private Short mainCauseId;
    @Column(name = "MAIN_CAUSE_DESCRIPTION", length = 1024)
    private String mainCauseDescription;
    @Basic(optional = false)
    @Column(name = "MAIN_CAUSE_NAME", nullable = false, length = 100)
    private String mainCauseName;
    @Basic(optional = false)
    @Column(name = "MAIN_CAUSE_ORDER_NUMBER", columnDefinition = "tinyint UNSIGNED default 0", nullable = false)
    private short mainCauseOrderNumber;
    @Basic(optional = false)
    @Column(name = "MAIN_CAUSE_STATUS", columnDefinition = "boolean default true", nullable = false)
    private boolean mainCauseStatus;
    @OneToMany(mappedBy = "mainCause", fetch = FetchType.LAZY)
    @Cascade({CascadeType.DETACH})
    private List<SubCause> subCauseList;
    @OneToMany(mappedBy = "mainCause", fetch = FetchType.LAZY)
    @Cascade({CascadeType.DETACH})
    private List<RiskData> riskDataList;

    public MainCause() {
    }

    public MainCause(Short mainCauseId) {
        this.mainCauseId = mainCauseId;
    }

    public MainCause(Short mainCauseId, String mainCauseName, short mainCauseOrderNumber, boolean mainCauseStatus) {
        this.mainCauseId = mainCauseId;
        this.mainCauseName = mainCauseName;
        this.mainCauseOrderNumber = mainCauseOrderNumber;
        this.mainCauseStatus = mainCauseStatus;
    }

    public Short getMainCauseId() {
        return mainCauseId;
    }

    public void setMainCauseId(Short mainCauseId) {
        this.mainCauseId = mainCauseId;
    }

    public String getMainCauseDescription() {
        return mainCauseDescription;
    }

    public void setMainCauseDescription(String mainCauseDescription) {
        this.mainCauseDescription = mainCauseDescription;
    }

    public String getMainCauseName() {
        return mainCauseName;
    }

    public void setMainCauseName(String mainCauseName) {
        this.mainCauseName = mainCauseName;
    }

    public short getMainCauseOrderNumber() {
        return mainCauseOrderNumber;
    }

    public void setMainCauseOrderNumber(short mainCauseOrderNumber) {
        this.mainCauseOrderNumber = mainCauseOrderNumber;
    }

    public boolean getMainCauseStatus() {
        return mainCauseStatus;
    }

    public void setMainCauseStatus(boolean mainCauseStatus) {
        this.mainCauseStatus = mainCauseStatus;
    }

    @XmlTransient
    public List<SubCause> getSubCauseList() {
        return subCauseList;
    }

    public void setSubCauseList(List<SubCause> subCauseList) {
        this.subCauseList = subCauseList;
    }

    @XmlTransient
    public List<RiskData> getRiskDataList() {
        return riskDataList;
    }

    public void setRiskDataList(List<RiskData> riskDataList) {
        this.riskDataList = riskDataList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (mainCauseId != null ? mainCauseId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof MainCause)) {
            return false;
        }
        MainCause other = (MainCause) object;
        if ((this.mainCauseId == null && other.mainCauseId != null) || (this.mainCauseId != null && !this.mainCauseId.equals(other.mainCauseId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.rbh.risk.entity.MainCause[ mainCauseId=" + mainCauseId + " ]";
    }
}
